package com.study.bean的属性注入;

import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author chenhs
 * @date 2019/9/7
 */
public class Test {
	
	@org.junit.Test
	 public void demo(){
		String xmlPath="com/study/bean的属性注入/applictionContext.xml";
		ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext(xmlPath);
		User uuserId1 = applicationContext.getBean("userId1", User.class);
		uuserId1.show();
		System.out.println("------------------------构造函数注入----------------------");
		User uuserId2 = applicationContext.getBean("userId2", User.class);
		uuserId2.show();
		System.out.println("-------------------构造函数注入---------------------------");
		User userId3 = applicationContext.getBean("userId3", User.class);
		Pen pen = userId3.getPen();
		System.out.println(pen.PEN);
		System.out.println("-----------set注入---------------");
		Car carId = applicationContext.getBean("carId",Car.class);
		carId.show();
		System.out.println("--------------集合注入--------------");
		Gather gatherId = applicationContext.getBean("gatherId", Gather.class);
		System.out.println(gatherId);
	}
}
